<!DOCTYPE html>
<html>
<title>This tests that the controls' current time is updated after media is unloaded</title>
<script src="../media-controls.js"></script>
<video controls></video>
<script>
  if (window.testRunner)
    testRunner.waitUntilDone();

  var video = document.querySelector('video');
  enableTestMode(video);
  video.src = '../content/test.ogv';

  // Get the video into a playing state at currentTime > 0.
  video.autoplay = true;
  video.addEventListener('playing', _ => {
    video.addEventListener('seeked', _ => {
      // Remove src and reload. The controls should reset and not show a playing
      // state or currentTime > 0.
      video.removeAttribute('src');
      video.load();

      video.addEventListener('emptied', _ => {
        video.addEventListener('timeupdate', _ => {
        if (window.testRunner)
          setTimeout(function() {
            testRunner.notifyDone();
          }, 10);
        });
      });
    });

    video.currentTime = 3;
  }, { once: true });
</script>
</html>
